<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;

class CreateCategoriesTable extends Migration
{
    public function up()
    {
        Schema::create('categories', function (Blueprint $table) {
            $table->increments('id');

            $table->string('name');
            $table->string('slug');
            $table->string('url_type')->default('id')->comment('URL的生成方式');
            $table->unsignedInteger('parent_id')->default(0)->comment('父级ID');
            $table->unsignedSmallInteger('order')->default(0)->comment('排序');
            $table->string('seo_title')->default('')->comment('seo的标题');
            $table->string('seo_keywords')->default('')->comment('seo的关键词');
            $table->string('seo_description')->default('')->comment('seo的描述');
            $table->boolean('show_in_menus')->default(true)->comment('是否在目录展示');
            $table->boolean('page')->default(false)->comment('是否单页');
            $table->text('page_html')->comment('如果是单页，这里存单页的html');
            $table->timestamps();
            $table->softDeletes();

            $table->unique('slug');
        });
    }

    public function down()
    {
        Schema::dropIfExists('categories');
    }
}
